Time Synchronization Method and Device

ABSTRACT

A time synchronization method and a device, where the method includes generating, by a first device, a first time synchronization frame according to a first coding scheme, where the first time synchronization frame includes a first frame header and a first time of day (TOD), the first frame header carries an identifier of the first coding scheme, and the first coding scheme defines a boundary of the first time synchronization frame and a location of the first TOD in the first time synchronization frame, and sending, by the first device, the first time synchronization frame to a second device using a first single line to trigger the second device to identify the first time synchronization frame according to the identifier of the first coding scheme, to obtain the first TOD from the first time synchronization frame, and to trace a time of the first device according to the first TOD.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of U.S. patent application Ser. No.16/259,142 filed on Jan. 28, 2019, which is a continuation ofInternational Patent Application No. PCT/CN2016/094456 filed on Aug. 10,2016. Both of the aforementioned applications are hereby incorporated byreference in their entireties.

TECHNICAL FIELD

This application relates to the communications field, and in particular,to a time synchronization method and a device.

BACKGROUND

In a time synchronization solution, time synchronization may be requiredbetween different types of devices or devices of differentmanufacturers. For example, time synchronization is required between aGlobal Positioning System (GPS) receiver and a building integratedtiming supply (BITS) device, time synchronization is required between aBITS and a transport bearer device, time synchronization is requiredbetween transport bearer devices, time synchronization is requiredbetween a transport bearer device and a base station device, and timesynchronization is required between a satellite positioning systemreceiver and a base station device. The foregoing scenarios may berelated to interworking between time interfaces. The time interface isused to transmit a one pulse per second (1PPS) and a time of day (TOD).

However, in a current solution, the TOD is transmitted depending on atechnical solution defined in the China Communications StandardsAssociation (CCSA). Further, one line needs to be occupied when the TODis transmitted, and another line needs to be occupied when a 1PPS signal(that is, a frame header) is transmitted. More line resources areoccupied in the other approaches, and consequently line resources arewasted.

SUMMARY

Embodiments of this application provide a time synchronization methodand a device such that a TOD and a frame header can be transmitted usinga single line in order to save line resources.

According to a first aspect, a time synchronization method is provided,including generating, by a first device, a first time synchronizationframe according to a first coding scheme, where the first timesynchronization frame includes a first frame header and a first TOD, thefirst frame header carries an identifier of the first coding scheme, andthe first coding scheme defines a boundary of the first timesynchronization frame and a location of the first TOD in the first timesynchronization frame, and sending, by the first device, the first timesynchronization frame to a second device using a first single line inorder to trigger the second device to identify the first timesynchronization frame according to the identifier of the first codingscheme, obtain the first TOD from the first time synchronization frame,and trace a time of the first device according to the first TOD.

The first device generates, according to the first coding scheme, thefirst time synchronization frame including the first TOD and the firstframe header, where the first frame header carries the identifier of thefirst coding scheme, and the first coding scheme defines the boundary ofthe first time synchronization frame and the location of the first TODin the first time synchronization frame, and sends the first timesynchronization frame to the second device using a single line such thatthe second device identifies the first time synchronization frameaccording to the identifier of the first coding scheme, obtains thefirst TOD from the first time synchronization frame, and traces the timeof the first device according to the first TOD in order to save lineresources.

In some possible implementations, the method further includes receiving,by the first device, a second time synchronization frame from a thirddevice using a second single line, where the second time synchronizationframe is generated by the third device according to a second codingscheme, the second time synchronization frame includes a second TOD anda second frame header, the second frame header carries an identifier ofthe second coding scheme, and the second coding scheme defines aboundary of the second time synchronization frame and a location of thesecond TOD in the second time synchronization frame, identifying, by thefirst device, the second time synchronization frame according to theidentifier of the second coding scheme, and obtaining the second TODfrom the second time synchronization frame, and tracing, by the firstdevice, a time of the third device according to the second TOD.

The first device keeps time synchronization with the third device, and aspecific process is the same as the process in which the second devicekeeps time synchronization with the first device. That is, the firstdevice may receive and send time information simultaneously such thattracing and protection of multiple devices may be implemented.

In some possible implementations, the method further includes receiving,by the first device, a second time synchronization frame from a thirddevice using a second single line, where the second time synchronizationframe is generated by the third device according to a second codingscheme, the second time synchronization frame includes a second TOD anda second frame header, the second frame header carries an identifier ofthe second coding scheme, and the second coding scheme defines aboundary of the second time synchronization frame and a location of thesecond TOD in the second time synchronization frame, identifying, by thefirst device, the second time synchronization frame according to theidentifier of the second coding scheme, and obtaining the second TODfrom the second time synchronization frame, determining, by the firstdevice, a delay for transmitting the second time synchronization framefrom the first device to the third device, correcting, by the firstdevice, the second TOD according to the delay, and tracing, by the firstdevice, a time of the third device according to the corrected secondTOD.

The first device corrects the TOD according to the delay between thefirst device and the third device such that a time of the first devicemay be precisely consistent with that of the third device by means oftime correction, that is, the first device keeps time synchronizationwith the third device.

In some possible implementations, that the first device determines adelay for transmitting the second time synchronization frame from thefirst device to the third device includes sending, by the first deviceat a first time, the second time synchronization frame to the thirddevice using the second single line, receiving, by the first device at asecond time, the second time synchronization frame returned by the thirddevice, and determining, by the first device, that the delay fortransmitting the second time synchronization frame from the first deviceto the third device is equal to half of a difference between the secondtime and the first time.

In this embodiment of this application, after receiving the first timesynchronization frame, the first device may perform automatic delaymeasurement. With the automatic delay measurement of the first device,manual delay measurement is avoided such that engineering deployment isreduced.

In some possible implementations, the first time synchronization framefurther carries a first time source identifier.

In this embodiment of this application, the first time synchronizationframe may carry the first time source identifier of the first device,for example, identity (ID) information. The first time synchronizationframe may further include priority information of the first device, ormay further include other information and the like. This is not limitedin this application. In this embodiment of this application, a timesource identifier is carried in a time synchronization frame. Inlarge-scale networking, a time source may still be accurately obtained.This reduces costs for repairing a line, and improves reliability.

In some possible implementations, the first time synchronization framefurther carries first frequency information, and the first timesynchronization frame is further used to trigger the second device totrace the time of the first device according to the first frequencyinformation.

The first time synchronization frame may further carry the firstfrequency information. For example, one bit is transmitted every 31.25microseconds (μs), that is, a frequency is 32 kilohertz (KHz). In thisway, the first device does not need to add extra deployment of a 2megabits per second (Mbps) external clock interface or a line. Thisreduces engineering deployment, and reduces a waste of line resources.

In some possible implementations, the second device and the third deviceare a same device. That is, bidirectional transmission of timeinformation between two devices may be implemented.

In some possible implementations, the second time synchronization framefurther carries a second time source identifier.

The second time source identifier and the first time source identifiermay be the same, or may be different. This is not limited in thisapplication.

In some possible implementations, the second time synchronization framefurther carries second frequency information, and that the first devicetraces a time of the third device according to the corrected second TODincludes tracing, by the first device, the time of the third deviceaccording to the corrected second TOD and the second frequencyinformation.

When the first device needs to trace the time of the third device, timesof the two devices need to be consistent at any time. The second timesynchronization frame may further carry second frequency informationsuch that the first device traces the time of the third device accordingto the frequency information and the corrected time information. In thisway, the first device does not need to add extra deployment of a 2 Mbpsexternal clock interface or a line. This reduces engineering deployment,and reduces a waste of line resources.

According to a second aspect, a first device is provided, and the firstdevice includes all units that are used to execute the method accordingto the first aspect or any one of possible implementations of the firstaspect.

According to a third aspect, a first device is provided, including aprocessor and a memory.

The memory stores a program, and the processor executes the program inorder to execute the time synchronization method according to the firstaspect or any one of the possible implementations of the first aspect.

According to a fourth aspect, a computer storage medium is provided. Thecomputer storage medium stores program code, and the program code isused to indicate an instruction that is used to execute the timesynchronization method according to the first aspect or any one of thepossible implementations of the first aspect.

Based on the foregoing technical solutions, in the embodiments of thisapplication, a first device generates, according to a first codingscheme, a first time synchronization frame including a first TOD and afirst frame header, where the first frame header carries an identifierof the first coding scheme, and the first coding scheme defines aboundary of the first time synchronization frame and a location of thefirst TOD in the first time synchronization frame, and sends the firsttime synchronization frame to a second device using a single line suchthat the second device identifies the first time synchronization frameaccording to the identifier of the first coding scheme, obtains thefirst TOD from the first time synchronization frame, and traces a timeof the first device according to the first TOD in order to save lineresources.

BRIEF DESCRIPTION OF DRAWINGS

To describe the technical solutions in some of the embodiments of thisapplication more clearly, the following briefly describes theaccompanying drawings describing some of the embodiments. Theaccompanying drawings in the following description merely show someembodiments of this application, and persons of ordinary skill in theart can derive other drawings from these accompanying drawings withoutcreative efforts.

FIG. 1 is a schematic diagram of a coding scheme of the direct current(DC) Level Shift (DCLS) protocol;

FIG. 2A, FIG. 2B, and FIG. 2C are schematic diagrams of a coding schemeof the DCLS protocol;

FIG. 3 is a schematic diagram of a TOD transmission method;

FIG. 4 is a schematic diagram of a TOD transmission scheme;

FIG. 5 is a flowchart of interaction in a time synchronization methodaccording to an embodiment of this application;

FIG. 6 is a schematic diagram of a time synchronization method accordingto an embodiment of this application;

FIG. 7 is a schematic diagram of a time synchronization method accordingto an embodiment of this application;

FIG. 8 is a schematic diagram of a time synchronization method accordingto another embodiment of this application;

FIG. 9A and FIG. 9B are a schematic flowchart of a time synchronizationmethod according to another embodiment of this application;

FIG. 10 is a schematic block diagram of a first device according to anembodiment of this application; and

FIG. 11 is a schematic structural diagram of a first device according toan embodiment of this application.

DESCRIPTION OF EMBODIMENTS

The following clearly describes the technical solutions in theembodiments of this application with reference to the accompanyingdrawings in the embodiments of this application. The describedembodiments are some rather than all of the embodiments of thisapplication. All other embodiments can be obtained by persons ofordinary skill in the art based on the embodiments of this applicationwithout creative efforts.

An RS422 level uses a differential transmission manner, and generallyhas two pins A and B. When a voltage difference between a transmit end Aand a transmit end B is +2 to +6, it indicates “1”, and when the voltagedifference between the transmit end A and the transmit end B is −2 to−6, it indicates “0”. When a voltage difference between a receive end Aand a receive end B is greater than +200 millivolts (my), it indicates“1”, and when the voltage difference between the receive end A and thereceived end B is less than −200 my, it indicates “0”. A logical “1” isdefined as a state B>A, and a logical “0” is defined as a state A>B. Avoltage difference between A and B is not less than 200 my. When aone-to-one connector is used, the RS422 level supports onlyunidirectional transmission and half-duplex communication, and a maximumtransmission rate is 10 Mbps.

Differential transmission is a signal transmission technology. Differentfrom use of a signal cable and a ground cable in a conventionaltechnology, in the differential transmission, signals are transmittedover the two cables. Amplitudes of the two signals are the same, butphases of the two signals are opposite. A signal transmitted over thetwo cables is a differential signal. For the differential signal, avalue is used to represent a difference between two physical quantities.The differential signal is also referred to as a differential modesignal, which is relative to a common mode signal.

The DCLS includes day, hour, minute, second, and control information. Asshown in FIG. 1, two consecutive broad pulses of 8 milliseconds (ms)indicate a start of second. If elements are encoded at the second 8 ms,the elements are respectively element 0, element 1, element 2, . . . ,and element 99. A time format includes day, hour, minute, and second,and a time sequence is second-minute-hour-day. Occupied information bitsare as follows. The second occupies 7 bits, the minute occupies 7 bits,the hour occupies 6 bits, and the day occupies 10 bits. Locations of theday, hour, minute, and second are between P0 to P5. P6 to P0 includeother control information. Information about “second” includes element1, element 2, element 3, element 4, element 6, element 7, and element 8,information about “minute” includes element 10, element 11, element 12,element 13, element 15, element 16, and element 17, and informationabout “hour” includes element 20, element 21, element 22, element 23,element 25, and element 26. Element 5, element 14, and element 24 areindex markers with a width of 2 ms. All the hour, minute, and second arerepresented using a Binary Coded Decimal (BCD) code (that is, a binarycode of ten values from “0” to “9”). A low bit precedes a high bit, anda tens place follows a ones place.

In a specific physical coding scheme, 1 second (s) is equally dividedinto 100 timeslots. Each timeslot includes 10 ms. A timeslot in which ahigh level lasts for 8 ms and a low level lasts for 2 ms identifiessynchronization (as shown in FIG. 2A), two consecutive synchronizationsignals identify a start of second, a timeslot in which a high levellasts for 5 ms and a low level lasts for 5 ms identifies a logical “1”(as shown in FIG. 2B), and a timeslot in which a high level lasts for 2ms and a low level lasts for 8 ms identifies a logical “0” (as shown inFIG. 2C).

FIG. 3 shows a schematic diagram of a TOD transmission method. Asdefined by the CCSA, for TOD transmission, a baud rate is 9600 bydefault, no parity check is performed, one start bit (which is indicatedusing a low level) and one stop bit (which is indicated using a highlevel) are used, an idle frame is indicated using a high level, thereare eight data bits, and transmission of the TOD should start after a1PPS rises by 1 ms and should be completed within 500 ms. The TODindicates a time at which the current 1PPS triggers a rising edge. Inaddition, a sending frequency of a TOD protocol packet is once persecond.

Further, the 1PPS and the TOD are transmitted in an RS422 level manner.A used physical connector is an RJ45 connector or a DB9 connector, andelectrical characteristics of the physical connector meet acorresponding standard requirement. A line order requirement is shown inTable 1.

TABLE 1 PIN Signal definition Description 1 NC A default state isnon-connected (high impedance). 2 NC A default state is non-connected(high impedance). 3 422_1_N 1PPS 4 GND RS422 level GND 5 GND RS422 levelGND 6 422_1_P 1PPS 7 422_2_N TOD time information 8 422_2_P TOD timeinformation

FIG. 4 shows a schematic diagram of a TOD transmission scheme. As shownin FIG. 4, a grandmaster (GM) clock and a device 1 implement timesynchronization using the Synchronous Ethernet (SyncE) and the PrecisionTime Protocol (PTP), that is, by carrying a TOD using a frame spacing ofan Ethernet frame. The frame spacing may be included in an Ethernet datastream. The Ethernet data stream may be a Gigabit Ethernet (GE) datastream. That is, a first device may perform time synchronization using aservice interface, and the service interface supports a timesynchronization function defined in the Institute of Electrical andElectronics Engineers (IEEE) 1588-2008 formulated by the IEEE. An extraservice interface needs to be occupied when the service interfacesupports the time synchronization function in the IEEE 1588-2008.Alternatively, a dedicated 10 gigabit Small Form-factor Pluggable(XFP)/Small Form-factor Pluggable (SFP) module interface needs to bedeveloped such that the service interface supports the timesynchronization in the IEEE 1588-2008, and costs are relatively high.

Alternatively, for TOD transmission between a device 1 and a device 2,the device 1 and the device 2 implement time synchronization using eightlines in Table 1. Two lines are connected to ground (GND), defaultstates of two lines are non-connected (NC), and four lines in two groupsare used to send the TOD using a 1PPS and a TOD. Sending of a TOD signaland sending of a 1PPS signal are separately implemented by means ofdifferential transmission, that is, the TOD signal and the 1PPS signaleach occupy two lines. Therefore, transmission of the TOD signal and the1PPS signal occupies all of the four lines such that the TOD can betransmitted only unidirectionally, that is, each device may only receivethe TOD or send the TOD at a time. In addition, a dedicated 2 Mbpsexternal clock (CLK) interface is required between the device 1 and thedevice 2 to transmit clock frequency information, and the clockfrequency information is used for frequency synchronization betweennetwork elements.

Therefore, in the other approaches, sending of the TOD depends on the1PPS sent over another line, that is, a start time for transmitting theTOD needs to be determined according to a rising edge of the 1PPS. Theother approaches has the following disadvantages, line resources arewasted relatively severely, and the TOD can be transmitted onlyunidirectionally.

FIG. 5 shows a flowchart of interaction in a time synchronization methodaccording to an embodiment of this application.

Step 101. A first device generates a first time synchronization frameaccording to a first coding scheme, where the first time synchronizationframe includes a first frame header and a first TOD, the first frameheader carries an identifier of the first coding scheme, and the firstcoding scheme defines a boundary of the first time synchronization frameand a location of the first TOD in the first time synchronization frame.

The first device may obtain time information from a GM clock accordingto a frame spacing of an Ethernet frame, or the first device is the GMclock (for example, a BITS) and is configured to provide a timingservice for another device such that the first device may determine acurrent TOD. The first device generates the first time synchronizationframe according to the first coding scheme, where the first timesynchronization frame carries first frame header information and thefirst TOD, the first frame header information carries an identifier ofthe first coding scheme, and the first coding scheme defines a boundaryof the first time synchronization frame and the location of the firstTOD in the first time synchronization frame. Further, some commonly usedsoftware programs are further required to generate the first timesynchronization frame. This is not limited in this application.

The identifier of the first coding scheme may indicate an internalstructure of the first time synchronization frame, a length of anoccupied field, a specific frame header location and frame trailerlocation (represented as the boundary of the first time synchronizationframe), content corresponding to different fields (that is, a field thatis in the first time synchronization frame and that indicates the firstTOD may be learned), and the like.

Optionally, the first coding scheme defines that the first timesynchronization frame includes 100 timeslots, one bit is transmittedevery 31.25 μs, and 10 bits may be transmitted in a time length of onetimeslot, that is, one timeslot is 312.5 μs, and when a duty cycle of ahigh level is 75%, it indicates a start time for sending a timesynchronization frame (as shown in FIG. 6), and the like. That is, asecond device may identify the first time synchronization frameaccording to the identifier of the first coding scheme, and may learnthe location of the TOD from the first time synchronization frame, andfurther obtain the first TOD.

It should be understood that the first coding scheme may be determinedaccording to the DCLS protocol. The DCLS carries element informationusing a direct current bit, and the DCLS is transmitted using a digitalpath without limitation of a transmission distance. The DCLS identifiesa start of second using two consecutive synchronization signals. Eachtimeslot is 10 ms, and one bit is transmitted in one timeslot.

It should be further understood that this application imposes nolimitation on a quantity of timeslots that form the first timesynchronization frame, a quantity of bits that can be transmitted ineach timeslot, content corresponding to each bit, and the like.

It should be noted that the first device may be any network device thatcan meet the foregoing proprietary protocol, such as a wavelengthdivision device, a satellite positioning system receiver, a core networkdevice, an aggregation network device, a base station, a base stationcontroller, a server, an optical transport network device, a packettransport network device, or a switch. This is not limited in thisapplication.

The GM clock may be any device that is used to provide a timing service,such as a satellite, a satellite positioning system receiver, awavelength division device, a core network device, an aggregationnetwork device, a base station, a base station controller, a server, ora switch. This is not limited in this application.

For example, the satellite positioning system receiver provides a timingservice by successively using a wavelength division device, a router, abase station, and the like, or the satellite positioning system receiverprovides a timing service by successively using a wavelength divisiondevice, a router, a base station, a router, a base station, and thelike.

Optionally, the first time synchronization frame may convert 0, 1, 2, 3,. . . , 9 that are used to indicate year, month, day, hour, minute, andsecond in the time information to binary-coded signals (“0” and “1”) forrepresentation. For example, when a duty cycle of a high level is 25%,it indicates “1”, and when a duty cycle of a high level is 50%, itindicates “0” (as shown in FIG. 6).

Data transmission content in each timeslot is shown in the followingTable 2. An undefined idle timeslot may be made readable and writable bysoftware such that a function may be expanded in the future.

TABLE 2 Timeslot Bit Filling number Function description width Remarksmodule ts 1 Used for sending a frame 1 Value range: 0 Logic sequencenumber. The byte to 255 frame sequence number increases by 1 for eachframe. The value of the frame sequence number ranges from 0 to 255.Frame sequence numbers are numbered from 0 to 255 again after 255 framesare sent. ts 2~ts 11 Used for sending a PTP 10 N/A Logic timecorresponding to a bytes frame header. ts 12~ts 16 Used for sending ashare 5 N/A Logic memory-fabric interface bytes chip (SM-FIC) timecorresponding to a frame header. ts 17~ts 36 Used for sending 20 N/A Thelogic network element bytes automatically declaration information. sendsa value configured by software ts 37 Used for sending a 1 N/A The logicsynchronization status byte automatically marker (SSM) byte. sends avalue configured by software ts 38 Used for sending a 1 Subrack Thelogic subrack number. byte number automatically sends a value configuredby software ts 39 Used for sending a 1 Cascade port The logic cascadeport number. byte number: automatically TOD 0 −> 0 sends a value TOD 1−> configured by 70-OSC 1 −> 2 software 70-OSC 2 −> 3 78-OSC 1 −> 478-OSC 2 −> 5 ts 40 Operating mode 1 Mode: The logic byte 0: normalautomatically mode sends a value 1: delay configured by measurementsoftware ts 41 N/A N/A N/A N/A . . . . . . . . . . . . . . . ts 99~ts100 To improve reliability, a 2 N/A Logic cyclic redundancy check bytes(CRC) code is transmitted, and the CRC check can be disabled.

The PTP time occupies a bit width of 10 bytes and is used to indicateyear, month, day, hour, minute, and second in the time information. TheSSM byte is used to indicate a quality level of a signal in a timesynchronization process.

Optionally, the first time synchronization frame further carries a firsttime source identifier.

Further, in the other approaches, when two devices perform timesynchronization by sending the TOD, time source information is not sent.As a result, each time the TOD passes through a line interface, a timesource becomes a local time source. In large-scale networking, timesources in an entire network are not clear. Consequently, when a line isfaulty, costs for detecting a fault source are relatively high.

In this embodiment of this application, the first time synchronizationframe may carry the first time source identifier of the first device,for example, ID information. The first time synchronization frame mayfurther include priority information of the first device, or may furtherinclude other information. This is not limited in this application. Inthis embodiment of this application, a time source identifier is carriedin a time synchronization frame. In large-scale networking, a timesource may still be accurately obtained. This reduces costs forrepairing a line, and improves reliability.

Step 102. The first device sends the first time synchronization frame toa second device using a first single line in order to trigger the seconddevice to identify the first time synchronization frame according to theidentifier of the first coding scheme, obtain the first TOD from thefirst time synchronization frame, and trace a time of the first deviceaccording to the first TOD.

The first device sends the first time synchronization frame to thesecond device using a single line. The first time synchronization frameincludes the first TOD and the first frame header, or may furtherinclude a time source identifier, frequency information, and the like.This is not limited in this application. This avoids a problem in theother approaches that a separate line is required to send a 1PPS,thereby reducing a waste of line resources for sending a TOD.

The single line mentioned in this application is a line used to transmita serial signal. For example, the single line may be implemented using apin of an RJ45 connector. It should be understood that the RJ45connector includes eight pins. Each of the eight pins may be used totransmit one serial signal. The eight pins as a whole transmit aparallel signal including eight serial signals. Therefore, the eightpins of the RJ45 connector may be lines used to transmit a parallelsignal.

In this application, that a device A traces a time of a device B meansthat the device A uses the device B as a GM clock of the device A inorder to calibrate a clock time in the device A.

Optionally, in an embodiment, the first time synchronization framefurther carries first frequency information, and the first frequencyinformation is further used to trigger the second device to trace thetime of the first device according to the first frequency information.

Further, in an embodiment of this application, the first timesynchronization frame further includes the first frequency information.The second device traces the time of the first device according to thefirst frequency information. For example, one bit is transmitted every31.25 μs, that is, a frequency is 32 KHz. In this way, the first devicedoes not need to add extra deployment of a 2 Mbps external clockinterface or a line. This reduces engineering deployment, and reduces awaste of line resources. The frequency may be obtained by dividing asystem clock frequency. For example, 38.88 Mbps is divided by 1215during frequency division, that is, 38.88 Mbps=38880 K=38880000 hertz(Hz), and 38880000/1215=32000 Hz.

In addition, the first coding scheme defines that the first timesynchronization frame includes 100 timeslots. 10 bits may be transmittedin a time length of one timeslot, and a frame frequency is 32000Hz/1000=32 Hz. Compared with the other approaches in which a TODtransmission frequency is once per second, in this embodiment of thisapplication, a TOD transmission rate can be improved.

It should be understood that, in this embodiment of this application, aninterface that is used to transmit a 1PPS and a TOD in the otherapproaches may be referred to as an “enhanced time interface”. This isnot limited in this application.

Step 103. The second device identifies the first time synchronizationframe, and obtains the first TOD from the first time synchronizationframe.

Further, the second device receives the first time synchronization framesent by the first device, where the first time synchronization frameincludes the first frame header and the first TOD, the first frameheader carries the identifier of the first coding scheme, and the firstcoding scheme defines the boundary of the first time synchronizationframe and the location of the first TOD in the first timesynchronization frame. The second device parses the time synchronizationframe according to the first coding scheme. In this way, the seconddevice can obtain the first time synchronization frame, and obtain thefirst TOD from the first time synchronization frame such that the seconddevice can trace the time of the first device according to the firstTOD.

Step 104. The second device traces the time of the first deviceaccording to the identified first TOD.

Optionally, the second device may keep more precise time synchronizationwith the first device according to the first TOD and the frequencyinformation in the first time synchronization frame in the embodiment ofthis application.

It should be noted that the second device further needs to perform phasesynchronization. However, this application imposes no limitation on amanner of phase synchronization.

Optionally, the method further includes receiving, by the first device,a second time synchronization frame from a third device using a secondsingle line, where the second time synchronization frame is generated bythe third device according to a second coding scheme, the second timesynchronization frame includes a second TOD and a second frame header,the second frame header carries an identifier of the second codingscheme, and the second coding scheme defines a boundary of the secondtime synchronization frame and a location of the second TOD in thesecond time synchronization frame, identifying, by the first device, thesecond time synchronization frame according to the identifier of thesecond coding scheme, and obtaining the second TOD from the second timesynchronization frame, and tracing, by the first device, a time of thethird device according to the second TOD.

A manner of generating the second time synchronization frame is the sameas that of generating the first time synchronization frame. The secondtime synchronization frame includes the second TOD and the second frameheader, the second frame header carries the identifier of the secondcoding scheme, and the second coding scheme defines the boundary of thesecond time synchronization frame and the location of the second TOD inthe second time synchronization frame. The first device keeps timesynchronization with the third device, and a specific process is thesame as the process in which the second device keeps timesynchronization with the first device. To avoid repetition, details arenot described herein again. That is, the first device may receive andsend a time synchronization frame simultaneously (that is, receiving andsending the TOD simultaneously), that is, the first device may trace thetime of the third device, and the second device may trace the time ofthe first device such that multiple devices may keep timesynchronization with each other.

It should be understood that the first time synchronization frame andthe second time synchronization frame may be completely the same, orpartially different (for example, only coding schemes are the same, butTOD content or frame header content is different), or completelydifferent. This is not limited in this application.

Optionally, the method further includes receiving, by the first device,a second time synchronization frame from a third device using a secondsingle line, where the second time synchronization frame is generated bythe third device according to a second coding scheme, the second timesynchronization frame includes a second TOD and a second frame header,the second frame header carries an identifier of the second codingscheme, and the second coding scheme defines a boundary of the secondtime synchronization frame and a location of the second TOD in thesecond time synchronization frame, identifying, by the first device, thesecond time synchronization frame according to the identifier of thesecond coding scheme, and obtaining the second TOD from the second timesynchronization frame, determining, by the first device, a delay fortransmitting the second time synchronization frame from the first deviceto the third device, correcting, by the first device, the second TODaccording to the delay, and tracing, by the first device, a time of thethird device according to the corrected second TOD.

Further, in an embodiment, the first device may receive the second timesynchronization frame sent, by the third device, over the second singleline. A manner of generating the second time synchronization frame isthe same as that of generating the first time synchronization frame. Thesecond time synchronization frame includes the second TOD and the secondframe header, the second frame header carries the identifier of thesecond coding scheme, and the second coding scheme defines the boundaryof the second time synchronization frame and the location of the secondTOD in the second time synchronization frame. The first device obtainsthe second TOD from the third device. The first device is not consistentwith the second TOD. The first device further needs to determine thedelay for transmitting the second time synchronization frame from thefirst device to the third device, and trace the time of the third deviceaccording to the second TOD and the delay.

It should be understood that time information of the first device may bemanually measured and corrected such that the first device keeps timesynchronization with the third device. This is not limited in thisapplication.

Optionally, in an embodiment, the second time synchronization framefurther carries second frequency information, and that the first devicetraces a time of the third device according to the corrected second TODincludes tracing, by the first device, the time of the third deviceaccording to the corrected second TOD and the second frequencyinformation.

When a device needs to trace a time of another device, times of the twodevices are required to be consistent at any time. In this embodiment ofthis application, the second time synchronization frame may furthercarry the second frequency information such that the first device tracesthe time of the third device according to the frequency information andthe corrected time information. In this way, the first device does notneed to add extra deployment of a 2 Mbps external clock interface or aline. This reduces engineering deployment, and reduces a waste of lineresources.

Optionally, in this embodiment of this application, that the firstdevice determines a delay for transmitting the second timesynchronization frame from the first device to the third device includessending, by the first device at a first time, the second timesynchronization frame to the third device using the second single line,receiving, by the first device at a second time, the second timesynchronization frame returned by the third device, and determining, bythe first device, that the delay for transmitting the second timesynchronization frame from the first device to the third device is equalto half of a difference between the second time and the first time.

Further, in this embodiment of this application, after receiving thesecond time synchronization frame, the first device may performautomatic delay measurement. FIG. 7 shows a schematic diagram ofperforming automatic delay measurement by the first device. With theautomatic delay measurement of the first device, manual delaymeasurement is avoided such that engineering deployment is reduced.

For example, a subrack A (that is, a function module of the firstdevice) sends the second time synchronization frame to a subrack B (thatis, a function module of the third device).

A local PTP timestamp t1 (that is, a first time) is added to a time forsending the second time synchronization frame. A corresponding port ofthe subrack B is configured with a delay measurement mode. Whenreceiving the second time synchronization frame, the subrack B directlyperforms outloop on the received second time synchronization frame, andreturns the second time synchronization frame to the subrack A. Thesubrack A adds a local PTP timestamp t2 (that is, a second time) to atime for receiving the returned second time synchronization frame.

It should be noted that when receiving the returned second timesynchronization frame, the subrack A needs to determine whether thereceived frame is the second time synchronization frame sent by thesubrack A in order to ensure that a frame sequence number is correct.This avoids an error that is caused because a delay calculation isperformed on a sending time and a receiving time that are of differentframes. Further, the subrack A may determine, according to a subracknumber, a port number, or the like, whether the received frame is thesecond time synchronization frame sent by the subrack A. This is notlimited in this application.

The first device may calculate a unidirectional path delay according toa first time for sending the second time synchronization frame and asecond time for receiving the returned second time synchronizationframe. Further, the delay is (t₂−t₁)/2, and the subrack A saves thedelay. The first device corrects, according to the determined delay andfirst time information, time information based on the first timeinformation such that a time of the first device is consistent with atime of the third device, that is, the first device keeps timesynchronization with the third device.

For example, the time synchronization method may be applied to a ringprotection scenario, as shown in FIG. 8. A device 1, a device 2, and adevice 3 are co-site devices. When a GM clock (that is, a time source)is normal, the device 1 keeps time synchronization with the GM clock,and then sends a first time synchronization frame to the device 2 anddevice 3 using an interface such that the device 2 keeps timesynchronization with the device 1, and the device 3 keeps timesynchronization with the device 1. In addition, the device 3 (which maybe considered as a first device) may further send a second timesynchronization frame to the device 2 such that the device 2 keeps timesynchronization with the device 3. That is, the device 3 can receive atime synchronization frame (for example, TOD_RX in FIG. 8) from thedevice 1, and can send a time synchronization frame (for example, TOD_TXin FIG. 8) to the device 2.

A second device may also automatically detect a delay between the seconddevice and the first device, and a specific process is the same as theprocess in which the first device automatically detects a delay betweenthe first device and a third device. To avoid repetition, details arenot described herein again.

It should be understood that the first time synchronization frame andthe second time synchronization frame may be the same, or may bedifferent, and a first TOD and a second TOD may be the same, or may bedifferent. This is not limited in this application.

For example, the third device sends the second time synchronizationframe to the first device such that the first device synchronizes withthe third device, and then the first device immediately sends the firsttime synchronization frame to the second device such that the seconddevice synchronizes with the first device. Therefore, theoretically, aTOD in the first time synchronization frame and a TOD in the second timesynchronization frame are the same, however, there is an error in anactual situation, and the error is generally less than 100 nanoseconds(ns).

Optionally, in this embodiment of this application, the third device andthe second device may be a same device.

For example, in the ring protection scenario shown in FIG. 8, when theGM clock is faulty, a secondary clock keeps time synchronization withthe device 3. In this way, the device 3 may send a time synchronizationframe to the device 1 such that the device 1 keeps time synchronizationwith the device 3.

Based on the foregoing description, it may be learned that, in thisembodiment of this application, a time synchronization frame isgenerated according to time information such that bidirectionaltransmission between devices and time synchronization between differentdevices may be implemented. For example, a transmission direction may bedetermined according to a device priority in order to fully use idleline resources, and the device priority may be determined according to adistance between a device and a time source. This is not limited in thisapplication.

Therefore, according to the time synchronization method provided in thisembodiment of this application, a first device generates, according to afirst coding scheme, a first time synchronization frame including afirst TOD and a first frame header, where the first frame header carriesan identifier of the first coding scheme, and the first coding schemedefines a boundary of the first time synchronization frame and alocation of the first TOD in the first time synchronization frame, andsends the first time synchronization frame to a second device using asingle line such that the second device identifies the first timesynchronization frame according to the identifier of the first codingscheme, obtains the first TOD from the first time synchronization frame,and traces a time of the first device according to the first TOD,thereby saving line resources and implementing bidirectionaltransmission of time information between devices.

It should be understood that sequence numbers of the foregoing processesdo not mean execution sequences in various embodiments of thisapplication. The execution sequences of the processes should bedetermined according to functions and internal logic of the processes,and should not be construed as any limitation on the implementationprocesses of the embodiments of this application.

The following describes in detail an embodiment of this application withreference to FIG. 9A and FIG. 9B. It should be noted that thedescription is merely intended to help persons skilled in the art betterunderstand this embodiment of this application, but are not intended tolimit the scope of this embodiment of this application. Meanings ofvarious terms in this embodiment of this application are the same asthose in the foregoing embodiments.

Step 310. A first device generates a first time synchronization frameaccording to a first coding scheme, where the first time synchronizationframe includes a first frame header and a first TOD, and the first frameheader carries an identifier of the first coding scheme.

The first device may obtain a TOD from a GM clock according to a serviceflow and the like, or the first device is the GM clock and is configuredto provide a timing service for another device such that the firstdevice may generate the first time synchronization frame.

Step 320. The first device sends the first time synchronization frame toa second device using a single line.

Step 330. The second device identifies the first time synchronizationframe according to the identifier of the first coding scheme that iscarried in the first frame header, and obtains the first TOD from thefirst time synchronization frame.

Step 340. The second device sends the first time synchronization frameto the first device at a time 1.

After receiving the first time synchronization frame, the first devicemay perform automatic delay measurement. A measurement signal carriesmeasurement information and measurement signal header information, andthe measurement signal header information is used to indicate a codingscheme of the measurement signal.

Step 350. The second device receives the returned first timesynchronization frame at a time 2.

Step 360. The second device determines half of a difference between thetime 2 and the time 1 as a delay 1 between the second device and thefirst device.

Step 370. The second device keeps time synchronization with the firstdevice according to the delay 1 and the first TOD.

Step 380. A third device generates a second time synchronization frameaccording to a second coding scheme, where the second timesynchronization frame includes a second frame header and a second TOD,and the second frame header carries an identifier of the second codingscheme.

Step 390. The third device sends the second time synchronization frameto the first device using a single line.

Step 400. The first device identifies the second time synchronizationframe according to the identifier of the second coding scheme that iscarried in the second frame header, and obtains the second TOD from thesecond time synchronization frame.

Step 410. The first device sends the second time synchronization frameto the third device at a time 3.

Step 420. The first device receives, at a time 4, the second timesynchronization frame returned by the third device.

When receiving the measurement signal, the first device needs todetermine whether a received frame is a time synchronization frame sentby the first device in order to ensure that a frame sequence number iscorrect. This avoids an error that is caused because a delay calculationis performed on a sending time and a receiving time that are ofdifferent frames.

Step 430. The first device determines half of a difference between thetime 4 and the time 3 as a delay 2 between the first device and thethird device.

Step 440. The first device keeps time synchronization with the thirddevice according to the delay 2 and the second TOD.

The first device may generate the first time synchronization frameaccording to the first coding scheme, and send the first timesynchronization frame to the second device in order to keep timesynchronization with the second device. Correspondingly, the firstdevice may further receive the second time synchronization frame that isgenerated by the third device according to the second coding scheme inorder to keep synchronization with the third device. That is, the firstdevice may receive a TOD and send a TOD simultaneously such that tracingand protection of multiple devices may be implemented.

It should be understood that step 370 to step 420 and step 310 to step360 may be performed simultaneously, that is, step 370 and step 310 maybe performed simultaneously, or step 370 may be performed before step310. This is not limited in this application.

It should be further understood that, for a specific manner ofindicating the corresponding information, reference may be made to theforegoing embodiments. For brevity, details are not described hereinagain.

Therefore, according to the time synchronization method provided in thisembodiment of this application, a first device generates, according to afirst coding scheme, a first time synchronization frame including afirst TOD and a first frame header, where the first frame header carriesan identifier of the first coding scheme, and the first coding schemedefines a boundary of the first time synchronization frame and alocation of the first TOD in the first time synchronization frame, andsends the first time synchronization frame to a second device using asingle line such that the second device identifies the first timesynchronization frame according to the identifier of the first codingscheme, obtains the first TOD from the first time synchronization frame,and traces a time of the first device according to the first TOD,thereby saving line resources and implementing bidirectionaltransmission of time information between devices.

It should be understood that sequence numbers of the foregoing processesdo not mean execution sequences in various embodiments of thisapplication. The execution sequences of the processes should bedetermined according to functions and internal logic of the processes,and should not be construed as any limitation on the implementationprocesses of the embodiments of this application.

The foregoing describes in detail the time synchronization methodaccording to this embodiment of this application, and the followingdescribes a first device according to an embodiment of this application.

FIG. 10 shows a schematic block diagram of a first device 500 accordingto an embodiment of this application. The first device 500 may beconfigured to execute the method shown in FIG. 5. For terms related toand specific implementations of the first device 500, refer to thedescription of the embodiment shown in FIG. 5. As shown in FIG. 10, thefirst device 500 includes a generation unit 510 configured to generate afirst time synchronization frame according to a first coding scheme,where the first time synchronization frame includes a first frame headerand a first TOD, the first frame header carries an identifier of thefirst coding scheme, and the first coding scheme defines a boundary ofthe first time synchronization frame and a location of the first TOD inthe first time synchronization frame, and a sending unit 520 configuredto send the first time synchronization frame generated by the generationunit 510 to a second device using a first single line in order totrigger the second device to identify the first time synchronizationframe according to the identifier of the first coding scheme, obtain thefirst TOD from the first time synchronization frame, and trace a time ofthe first device according to the first TOD.

Therefore, according to the first device 500 provided in this embodimentof this application, the first device 500 generates, according to afirst coding scheme, a first time synchronization frame including afirst TOD and a first frame header, where the first frame header carriesan identifier of the first coding scheme, and the first coding schemedefines a boundary of the first time synchronization frame and alocation of the first TOD in the first time synchronization frame, andsends the first time synchronization frame to a second device using asingle line such that the second device identifies the first timesynchronization frame according to the identifier of the first codingscheme, obtains the first TOD from the first time synchronization frame,and traces a time of the first device according to the first TOD inorder to save line resources.

Optionally, in this embodiment of this application, the first device 500further includes a first receiving unit (not shown) configured toreceive a second time synchronization frame from a third device using asecond single line, where the second time synchronization frame isgenerated by the third device according to a second coding scheme, thesecond time synchronization frame includes a second TOD and a secondframe header, the second frame header carries an identifier of thesecond coding scheme, and the second coding scheme defines a boundary ofthe second time synchronization frame and a location of the second TODin the second time synchronization frame, a first identifying unit (notshown) configured to identify the second time synchronization frameaccording to the identifier of the second coding scheme, and obtain thesecond TOD from the second time synchronization frame, and a firsttracing unit (not shown) configured to trace a time of the third deviceaccording to the second TOD.

In this embodiment of this application, optionally, the first device 500further includes a second receiving unit (not shown) configured toreceive a second time synchronization frame from a third device using asecond single line, where the second time synchronization frame isgenerated by the third device according to a second coding scheme, thesecond time synchronization frame includes a second TOD and a secondframe header, the second frame header carries an identifier of thesecond coding scheme, and the second coding scheme defines a boundary ofthe second time synchronization frame and a location of the second TODin the second time synchronization frame, a second identifying unit (notshown) configured to identify the second time synchronization frameaccording to the identifier of the second coding scheme, and obtain thesecond TOD from the second time synchronization frame, a determiningunit (not shown) configured to determine a delay for transmitting thesecond time synchronization frame from the first device to the thirddevice, a correction unit (not shown) configured to correct the secondTOD according to the delay, and a second tracing unit (not shown)configured to trace a time of the third device according to thecorrected second TOD.

Optionally, the determining unit is further configured to send, at afirst time, the second time synchronization frame to the third deviceusing the second single line, receive, at a second time, the second timesynchronization frame returned by the third device, and determine thatthe delay for transmitting the second time synchronization frame fromthe first device to the third device is equal to half of a differencebetween the second time and the first time.

Optionally, in this embodiment of this application, first timeinformation is represented in a binary-coded form.

In this embodiment of this application, optionally, the first timesynchronization frame further carries a first time source identifier.

Optionally, in this embodiment of this application, the second timesynchronization frame further carries second frequency information, andthe second tracing unit is further configured to trace the time of thethird device according to the corrected second TOD and the secondfrequency information.

Optionally, in this embodiment of this application, the second timesynchronization frame further carries a second time source identifier.

Optionally, in this embodiment of this application, the second TOD isrepresented in a binary-coded form.

In this embodiment of this application, optionally, the second deviceand the third device are a same device.

Optionally, in this embodiment of this application, the first timesynchronization frame further carries first frequency information, andthe first time synchronization frame is further used to trigger thesecond device to trace the time of the first device according to thefirst frequency information.

The first device 500 in this embodiment of this application may becorresponding to a first device in a time synchronization methodaccording to an embodiment of this application, and the foregoing andother operations and/or functions of units in the first device 500 areseparately used to implement corresponding processes of the methods. Forbrevity, details are not described herein again.

Therefore, a first device provided in this embodiment of thisapplication generates, according to a first coding scheme, a first timesynchronization frame including a first TOD and a first frame header,where the first frame header carries an identifier of the first codingscheme, and the first coding scheme defines a boundary of the first timesynchronization frame and a location of the first TOD in the first timesynchronization frame, and sends the first time synchronization frame toa second device using a single line such that the second deviceidentifies the first time synchronization frame according to theidentifier of the first coding scheme, obtains the first TOD from thefirst time synchronization frame, and traces a time of the first deviceaccording to the first TOD, thereby saving line resources andimplementing bidirectional transmission of time information betweendevices.

FIG. 11 shows a structure of a first device according to an embodimentof this application. The first device shown in FIG. 11 may be configuredto implement the first device 500 shown in FIG. 10. Referring to FIG.11, the first device includes at least one processor 702 (for example, acentral processing unit (CPU)), at least one network interface 705 oranother communications interface, a memory 706, and at least onecommunications bus 703 that is configured to implement connection andcommunication between these apparatuses. The processor 702 is configuredto execute an executable module stored in the memory 706, for example, acomputer program. The memory 706 may include a high-speed random accessmemory (RAM), and may also include a non-volatile memory, for example,at least one magnetic disk memory. Communication connection to at leastone other network element is implemented using the at least one networkinterface 705 (which may be wired or wireless).

In some implementations, the memory 706 stores a program 7061, and theprocessor 702 executes the program 7061 in order to perform thefollowing operations of generating a first time synchronization frameaccording to a first coding scheme, where the first time synchronizationframe includes a first frame header and a first TOD, the first frameheader carries an identifier of the first coding scheme, and the firstcoding scheme defines a boundary of the first time synchronization frameand a location of the first TOD in the first time synchronization frame,and sending the first time synchronization frame to a second deviceusing the network interface 705 and using a first single line in orderto trigger the second device to identify the first time synchronizationframe according to the identifier of the first coding scheme, obtain thefirst TOD from the first time synchronization frame, and trace a time ofthe first device according to the first TOD.

It can be learned from the foregoing technical solution provided in thisembodiment of this application that a first time synchronization framecarrying a first TOD and first frame header information is generated,and the first time synchronization frame is sent to a second deviceusing a single line such that the second device keeps timesynchronization with the first device according to the first timesynchronization frame in order to save line resources.

Optionally, the processor 702 is further configured to receive a secondtime synchronization frame from a third device using the networkinterface 705 and using a second single line, where the second timesynchronization frame is generated by the third device according to asecond coding scheme, the second time synchronization frame includes asecond TOD and a second frame header, the second frame header carries anidentifier of the second coding scheme, and the second coding schemedefines a boundary of the second time synchronization frame and alocation of the second TOD in the second time synchronization frame,identify the second time synchronization frame according to theidentifier of the second coding scheme, and obtain the second TOD fromthe second time synchronization frame, and trace a time of the thirddevice according to the second TOD.

Optionally, the processor 702 is further configured to receive a secondtime synchronization frame from a third device using the networkinterface 705 and using a second single line, where the second timesynchronization frame is generated by the third device according to asecond coding scheme, the second time synchronization frame includes asecond TOD and a second frame header, the second frame header carries anidentifier of the second coding scheme, and the second coding schemedefines a boundary of the second time synchronization frame and alocation of the second TOD in the second time synchronization frame,identify the second time synchronization frame according to theidentifier of the second coding scheme, and obtain the second TOD fromthe second time synchronization frame, determine a delay fortransmitting the second time synchronization frame from the first deviceto the third device, correct the second TOD according to the delay, andtrace a time of the third device according to the corrected second TOD.

Optionally, the processor 702 is further configured to send, at a firsttime, the second time synchronization frame to the third device usingthe network interface 705 and using the second single line, receive,using the network interface 705 at a second time, the second timesynchronization frame returned by the third device, and determine thatthe delay for transmitting the second time synchronization frame fromthe first device to the third device is equal to half of a differencebetween the second time and the first time.

Optionally, first time information carried in the first timesynchronization frame is represented in a binary-coded form.

Optionally, the first time synchronization frame further carries a firsttime source identifier.

Optionally, the second time synchronization frame further carries secondfrequency information, and the processor 702 is further configured totrace the time of the third device according to the corrected second TODand the second frequency information.

Optionally, the second device and the third device are a same device.

Optionally, the second time synchronization frame further carries asecond time source identifier.

Optionally, the second TOD is represented in a binary-coded form.

Optionally, the first time synchronization frame further carries firstfrequency information, and the first time synchronization frame isfurther used to trigger the second device to trace the time of the firstdevice according to the first frequency information.

It can be learned from the foregoing technical solution provided in thisembodiment of this application that a first device generates, accordingto a first coding scheme, a first time synchronization frame including afirst TOD and a first frame header, where the first frame header carriesan identifier of the first coding scheme, and the first coding schemedefines a boundary of the first time synchronization frame and alocation of the first TOD in the first time synchronization frame, andsends the first time synchronization frame to a second device using asingle line such that the second device identifies the first timesynchronization frame according to the identifier of the first codingscheme, obtains the first TOD from the first time synchronization frame,and traces a time of the first device according to the first TOD,thereby saving line resources and implementing bidirectionaltransmission of time information between devices.

An embodiment of this application further provides a computer storagemedium, and the computer storage medium may store a program instructionthat is used to indicate any one of methods.

Optionally, the storage medium may be a memory 706.

The term “and/or” in this specification describes only an associationrelationship for describing associated objects and represents that threerelationships may exist. For example, A and/or B may represent thefollowing three cases, only A exists, both A and B exist, and only Bexists. In addition, the character “/” in this specification generallyindicates an “or” relationship between the associated objects.

It should be understood that sequence numbers of the foregoing processesdo not mean execution sequences in various embodiments of thisapplication. The execution sequences of the processes should bedetermined according to functions and internal logic of the processes,and should not be construed as any limitation on the implementationprocesses of the embodiments of this application.

Persons of ordinary skill in the art may be aware that the units andalgorithm steps in the examples described with reference to theembodiments disclosed in this specification may be implemented byelectronic hardware or a combination of computer software and electronichardware. Whether the functions are performed by hardware or softwaredepends on particular applications and design constraint conditions ofthe technical solutions. Persons skilled in the art may use differentmethods to implement the described functions for each particularapplication, but it should not be considered that the implementationgoes beyond the scope of this application.

It may be clearly understood by persons skilled in the art that, for thepurpose of convenient and brief description, for a detailed workingprocess of the foregoing system, apparatus, and unit, reference may bemade to a corresponding process in the foregoing method embodiments, anddetails are not described again.

In the several embodiments provided in this application, it should beunderstood that the disclosed system, apparatus, and method may beimplemented in other manners. For example, the described apparatusembodiment is merely an example. For example, the unit division ismerely logical function division and may be other division in actualimplementation. For example, multiple units or components may becombined or integrated into another system, or some features may beignored or not performed. In addition, the displayed or discussed mutualcouplings or direct couplings or communication connections may beimplemented through some interfaces, indirect couplings or communicationconnections between the apparatuses or units, or electrical connections,mechanical connections, or connections in other forms.

The units described as separate parts may or may not be physicallyseparate, and parts displayed as units may or may not be physical units,may be located in one position, or may be distributed on multiplenetwork units. Some or all of the units may be selected according toactual needs to achieve the objectives of the solutions of theembodiments.

In addition, function units in the embodiments of this application maybe integrated into one processing unit, or each of the units may existalone physically, or two or more units are integrated into one unit. Theintegrated unit may be implemented in a form of hardware, or may beimplemented in a form of a software function unit.

When the integrated unit is implemented in the form of a softwarefunction unit and sold or used as an independent product, the integratedunit may be stored in a computer-readable storage medium. Based on suchan understanding, the technical solutions of this applicationessentially, or the part contributing to the other approaches, or someof the technical solutions may be implemented in a form of a softwareproduct. The software product is stored in a storage medium, andincludes several instructions for instructing a computer device (whichmay be a personal computer, a server, or a network device) to performall or some of the steps of the methods described in the embodiments ofthis application. The foregoing storage medium includes any medium thatcan store program code, such as a universal serial bus (USB) flashdrive, a removable hard disk, a read-only memory (ROM), a RAM, amagnetic disk, or an optical disc.

The foregoing descriptions are merely specific implementations of thisapplication, but are not intended to limit the protection scope of thisapplication. Any variation or replacement readily figured out by personsskilled in the art within the technical scope disclosed in thisapplication shall fall within the protection scope of this application.Therefore, the protection scope of this application shall be subject tothe protection scope of the claims.

What is claimed is:
 1. A method implemented by a first device,comprising: generating a first time synchronization frame according to afirst coding scheme, wherein the first time synchronization framecomprises a first time of day (TOD) and a first identifier of the firstcoding scheme, and wherein the first coding scheme defines a firstboundary of the first time synchronization frame and a first location ofthe first TOD in the first time synchronization frame; and sending thefirst time synchronization frame to a second device using a first singleline.
 2. The method of claim 1, further comprising: receiving a secondtime synchronization frame generated according to a second coding schemefrom a third device using a second single line, wherein the second timesynchronization frame comprises a second TOD and a second frame header,wherein the second frame header carries a second identifier of thesecond coding scheme, and wherein the second coding scheme defines asecond boundary of the second time synchronization frame and a secondlocation of the second TOD in the second time synchronization frame;identifying the second time synchronization frame according to thesecond identifier; obtaining the second TOD from the second timesynchronization frame; and tracing a time of the third device accordingto the second TOD.
 3. The method of claim 2, wherein the second deviceand the third device are a same device.
 4. The method of claim 1,further comprising: receiving a second time synchronization framegenerated according to a second coding scheme from a third device usinga second single line, wherein the second time synchronization framecomprises a second TOD and a second frame header, wherein the secondframe header carries a second identifier of the second coding scheme,and wherein the second coding scheme defines a second boundary of thesecond time synchronization frame and a second location of the secondTOD in the second time synchronization frame; identifying the secondtime synchronization frame according to the second identifier; obtainingthe second TOD from the second time synchronization frame; determining adelay for transmitting the second time synchronization frame from thefirst device to the third device; correcting the second TOD according tothe delay; and tracing a time of the third device according to acorrected second TOD.
 5. The method of claim 4, wherein determining thedelay comprises: sending, at a first time, the second timesynchronization frame to the third device using the second single line;receiving, at a second time, the second time synchronization frame fromthe third device; and determining that the delay is equal to half of adifference between the second time and the first time.
 6. The method ofclaim 4, wherein the second time synchronization frame further carriessecond frequency information, and wherein tracing the time of the thirddevice comprises tracing the time of the third device according to thecorrected second TOD and the second frequency information.
 7. The methodof claim 1, wherein the first time synchronization frame further carriesfirst frequency information, and wherein the first time synchronizationframe further triggers the second device to trace a time of the firstdevice according to the first frequency information.
 8. The method ofclaim 1, wherein the first time synchronization frame further carriesone or more of a first time source identifier of the first device andpriority information of the first device.
 9. The method of claim 1,wherein the first time synchronization frame further carries one or moreof a first time source identifier of the first device and a second timesource identifier of the first device.
 10. The method of claim 9,wherein the first time source identifier of the first device isdifferent from the second time source identifier of the first device.11. The method of claim 1, wherein the identifier of the first codingscheme indicates one or more of an internal structure of the first timesynchronization frame, a length of an occupied field, a specific frameheader location, a frame trailer location, or content corresponding todifferent fields.
 12. The method of claim 1, further comprisingdetermining the first coding scheme according to a direct current (DC)level shift (DCLS) protocol.
 13. The method of claim 1, wherein thefirst single line is implemented using a pin of an RJ45 connector.
 14. Afirst device, comprising: a computer-readable storage medium storing aprogram; and a processor coupled to the computer-readable storagemedium, wherein the program causes the processor to be configured to:generate a first time synchronization frame according to a first codingscheme, wherein the first time synchronization frame comprises a firsttime of day (TOD) and a first identifier of the first coding scheme, andwherein the first coding scheme defines a boundary of the first timesynchronization frame and a first location of the first TOD in the firsttime synchronization frame; and send the first time synchronizationframe to a second device using a first single line.
 15. The first deviceof claim 14, wherein the program further causes the processor to beconfigured to: receive a second time synchronization frame generatedaccording to a second coding scheme from a third device using a secondsingle line, wherein the second time synchronization frame comprises asecond TOD and a second frame header, wherein the second frame headercarries a second identifier of the second coding scheme, and wherein thesecond coding scheme defines a boundary of the second timesynchronization frame and a second location of the second TOD in thesecond time synchronization frame; identify the second timesynchronization frame according to the identifier of the second codingscheme; obtain the second TOD from the second time synchronizationframe; and trace a time of the third device according to the second TOD.16. The first device of claim 15, wherein the second device and thethird device are a same device.
 17. The first device of claim 14,wherein the program further causes the processor to be configured to:receive a second time synchronization frame generated according to asecond coding scheme from a third device using a second single line,wherein the second time synchronization frame comprises a second TOD anda second frame header, wherein the second frame header carries a secondidentifier of the second coding scheme, and wherein the second codingscheme defines a boundary of the second time synchronization frame and asecond location of the second TOD in the second time synchronizationframe; identify the second time synchronization frame according to thesecond identifier; obtain the second TOD from the second timesynchronization frame; determine a delay for transmitting the secondtime synchronization frame from the first device to the third device;correct the second TOD according to the delay; and trace a time of thethird device according to a corrected second TOD.
 18. The first deviceof claim 17, wherein the program further causes the processor to beconfigured to: send, at a first time, the second time synchronizationframe to the third device using the second single line; receive, at asecond time, the second time synchronization frame from the thirddevice; and determine that the delay for transmitting the second timesynchronization frame from the first device to the third device is equalto half of a difference between the second time and the first time. 19.The first device of claim 17, wherein the second time synchronizationframe further carries second frequency information, and wherein theprogram further causes the processor to be configured to trace the timeof the third device according to the corrected second TOD and the secondfrequency information.
 20. The first device of claim 14, wherein thefirst time synchronization frame further carries first frequencyinformation, and wherein the first time synchronization frame furthertriggers the second device to trace time of the first device accordingto the first frequency information.
 21. A computer program productcomprising instructions for storage on a non-transitorycomputer-readable storage medium that, when executed by a processor,causes a computer to: generate a first time synchronization frameaccording to a first coding scheme, wherein the first timesynchronization frame comprises a first time of day (TOD) and a firstidentifier of the first coding scheme, and wherein the first codingscheme defines a boundary of the first time synchronization frame and afirst location of the first TOD in the first time synchronization frame;and send the first time synchronization frame to a second device using afirst single line.
 22. The computer program product of claim 21, whereinthe instructions further cause the computer to: receive a second timesynchronization frame generated according to a second coding scheme froma third device using a second single line, wherein the second timesynchronization frame comprises a second TOD and a second frame header,wherein the second frame header carries a second identifier of thesecond coding scheme, and wherein the second coding scheme defines aboundary of the second time synchronization frame and a second locationof the second TOD in the second time synchronization frame; identify thesecond time synchronization frame according to the second identifier;obtain the second TOD from the second time synchronization frame; andtrace a time of the third device according to the second TOD.
 23. Thecomputer program product of claim 21, wherein the instructions furthercause the computer to: receive a second time synchronization framegenerated according to a second coding scheme from a third device usinga second single line, wherein the second time synchronization framecomprises a second TOD and a second frame header, wherein the secondframe header carries a second identifier of the second coding scheme,and wherein the second coding scheme defines a boundary of the secondtime synchronization frame and a second location of the second TOD inthe second time synchronization frame; identify the second timesynchronization frame according to the second identifier; obtain thesecond TOD from the second time synchronization frame; determine a delayfor transmitting the second time synchronization frame from a firstdevice to the third device; correct the second TOD according to thedelay; and trace a time of the third device according to a correctedsecond TOD.
 24. The computer program product of claim 23, wherein theinstructions further cause the computer to: send, at a first time, thesecond time synchronization frame to the third device using the secondsingle line; receive, at a second time, the second time synchronizationframe from the third device; and determine that the delay fortransmitting the second time synchronization frame from the first deviceto the third device is equal to half of a difference between the secondtime and the first time.
 25. The computer program product of claim 23,wherein the second time synchronization frame further carries secondfrequency information, and wherein the instructions further cause thecomputer to trace the time of the third device according to thecorrected second TOD and the second frequency information.
 26. A method,comprising: receiving a first time synchronization frame, wherein thefirst time synchronization frame comprises a first time of day (TOD) andan identifier of a first coding scheme, and wherein the first codingscheme defines a boundary of the first time synchronization frame and alocation of the first TOD in the first time synchronization frame;identifying the first time synchronization frame according to theidentifier; obtaining the first TOD from the first time synchronizationframe; and tracing a time according to the first TOD.
 27. The method ofclaim 26, wherein the first time synchronization frame further comprisesa frame header, and wherein the frame header comprises the identifier.28. The method of claim 27, wherein the method is implemented by adevice, and wherein the device is one of a wavelength division device, asatellite positioning system receiver, a core network device, anaggregation network device, a base station, a base station controller, aserver, an optical transport network device, a packet transport networkdevice, or a switch.
 29. The method of claim 26, wherein receiving thefirst time synchronization frame comprises receiving the first timesynchronization frame through a first single line.
 30. A system,comprising: a second device; and a first device configured to: generatea first time synchronization frame according to a first coding scheme,wherein the first time synchronization frame comprises a first time ofday (TOD) and an identifier of the first coding scheme, and wherein thefirst coding scheme defines a boundary of the first time synchronizationframe and a location of the first TOD in the first time synchronizationframe; and send the first time synchronization frame to the seconddevice using a first single line.
 31. The system of claim 30, whereinthe second device is configured to: receive the first timesynchronization frame through the first single line; identify the firsttime synchronization frame according to the identifier of the firstcoding scheme; obtain the first TOD from the first time synchronizationframe; and trace a time of the first device according to the first TOD.